<?php
class Admin_LoginController
    extends Admin_Abstract
{
    public function indexAction()
    {
        $this->loadLayout();
        $this->renderLayout();
    }

    public function loginingAction()
    {
        $user = $this->getRequest()->getParam('user_name',null);
        $password = $this->getRequest()->getParam('password',null);

        if(!empty($user) && !empty($password)) {
            $userModel = new Model_Admin_User_Admin();
            if($userModel->login($user,$password)) {
                $this->_getSession()->setUserLoginedIn($userModel);
                $this->_redirect('admin/index/index');
            } else {
                $this->_redirect('admin/login');
            }
        } else {
            $this->_redirect('admin/login');
        }
    }

    public function logoutAction()
    {
        $this->_getSession()->logoutUser();
        $this->_redirect('admin/login');
    }
}